import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 38917
 * Date: 2025-03-07
 * Time: 19:11
 */
public class main4 {
    public static int[] sort(int[] array){
        for (int i = 0; i < array.length - 1; i++) {
            int flag = -1;
            for (int j = 0; j < array.length - i - 1; j++) {
                if (array[j] > array[j + 1]){
                    int temp = array[j];
                    array[j] = array[j + 1];
                    array[j + 1] = temp;
                    flag = 1;
                }
                if (flag == -1){
                    break;
                }
            }
        }

        return array;
    }
    public static void main(String[] args) {
        //给定一个整型数组, 实现冒泡排序(升序排序)
        int[] array = {6,5,4,3,2,1};
        System.out.println(Arrays.toString(sort(array)));
    }
}
